package eleven;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDPTalkServer {
    public static void main(String[] args) throws Exception {
        System.out.println("UDPServer 启动中...");
        DatagramSocket server = new DatagramSocket(9999);
        while (true) {
            byte[] container = new byte[1024 * 60];
            DatagramPacket packet = new DatagramPacket(container, 0, container.length);
            server.receive(packet);
            byte[] datas = packet.getData();
            int len = packet.getLength();
            String str = new String(datas, 0, len);
            System.out.println(str);
            if(str.equals("bye")){
                break;
            }
        }
        server.close();
    }
}
